//
// Created by Administrator on 2020/4/20.
//

#include <jni.h>
#include <iostream>
#include <time.h>
#include <chrono>
#include <android/log.h>

#define TAG "native-lib-->"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,TAG ,__VA_ARGS__) // 定义LOGD类型
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__) // 定义LOGI类型
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,TAG ,__VA_ARGS__) // 定义LOGW类型
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,TAG ,__VA_ARGS__) // 定义LOGE类型
#define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,TAG ,__VA_ARGS__) // 定义LOGF类型

extern "C" {
using namespace std;

jlong getTime();

JNIEXPORT jlong JNICALL Java_com_gqz_jbox2d_MainActivity_test(JNIEnv *env, jobject) {
    char str[30] = {'H', 'e', 'l', 'l', 'o', ',', 'J', 'N', 'I', '\0'};

    jlong s = getTime();

    int a = 1;
    long b = 1;
    float c = 1.0;
    double d = 1.0;

    for (int i = 0; i < 1000 * 1000 * 500; i++) {
        a++;
        b += a;
        c *= 0.0000000001f;
        d *= 10.0000000001;
    }

    return getTime() - s;
}

jlong getTime() {
    auto timeNow = chrono::duration_cast<chrono::milliseconds>(
            chrono::system_clock::now().time_since_epoch());
    LOGD("time=%lld",timeNow.count());
    return timeNow.count();
}

}

